const User = require('../models/User');

exports.updateTheme = async (req, res) => {
  const { theme } = req.body;
  const user = await User.findByPk(req.user.id);

  user.theme = theme;
  await user.save();

  res.json({ success: true });
};

exports.createGroup = async (req, res) => {
  const { groupName } = req.body;

  try {
    const group = await DeviceGroup.create({
      user_id: req.user.id,
      group_name: groupName
    });
    res.status(201).json(group);
  } catch (error) {
    res.status(400).json({ error: '创建分组失败' });
  }
};